home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13832 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: druid.borland.com!usenet
  2. From: pete@borland.com (Pete Becker)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: What is name-mangling? (mentioned in FAQ)
  5. Date: 27 Mar 1996 17:30:22 GMT
  6. Organization: Borland International
  7. Message-ID: <4jbtve$9nk@druid.borland.com>
  8. References: <4ik3s1$j7q@alcor.usc.edu> <3152e97b.62546054@news.primenet.com>
  9. NNTP-Posting-Host: pbecker.borland.com
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=ISO-8859-1
  12. X-Newsreader: WinVN 0.99.5
  13.  
  14. In article <3152e97b.62546054@news.primenet.com>, gbe@primenet.com says...
  15. >
  16. >Name-Mangling (also called decoration) 
  17.  
  18. It's only called "decoration" by Microsoft. The C++ community uses the term 
  19. "name mangling".
  20.  
  21. >is a method of encoding the number and
  22. >types of parameters that a function takes into the name of the function.  
  23. Thus,
  24. >the function prototype "void xyz(int x)" might look something like "$xyz$qvr"
  25. >if you examine the object file.  This is required in C++ to produce type-safe
  26. >linkage.  
  27.  
  28. It is not required, either technically or by the standard. It is a common 
  29. implementation technique.
  30.  
  31. >In C++, you are allowed to have functions that have the same name,
  32. >but differ only in the number or types of parameters that they take.  This is
  33. >something that is not allowed in normal C.  The compiler needs to resolve 
  34. these
  35. >identical names into unique names for the linker.  
  36.  
  37. Once again, implementation details. There's no inherent reason for linkers to 
  38. require readable names as the only mechanism for resolving references. It just 
  39. happens to be done that way on most systems.
  40.  
  41. >Thus, the need for mangled
  42. >names.  The problem is that name mangling is not defined as a standard.
  43. >Therefore, every compiler could use a different scheme and thus be unable to
  44. >link in libraries created by another compiler.
  45. >
  46.  
  47. Even if compilers used the same name mangling schemes, there are enough 
  48. differences in the way objects are laid out and used that you can't, in most 
  49. cases, use code produced by different compilers within the same program, even 
  50. if you could persuade the linker to link the various modules together.
  51.  
  52.